package com.jiang.demo.depotstable.store;

import com.jiang.demo.depotstable.domain.Store;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jiangzhe
 * @create 2021/5/12 14:40
 */
@Slf4j
@RestController
@RequestMapping(value = "/store")
public class StoreController {

    @Autowired
    StoreService storeService;

    @GetMapping(value = "add")
    public String addStore(@RequestParam(required = true) String name, @RequestParam(required = true) String address,
                           @RequestParam(required = true) int port){
        Store store = new Store();
        store.setName(name);
        store.setAddress(address);
        store.setPort(port);
        storeService.insertStore(store);
        return store.toString()+"\t成功添加";
    }
}
